package src.itheima.contex;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletContextDem02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = getServletContext();
        servletContext.setAttribute("username","aaa");

//        servletContext.removeAttribute("username");
        String servletContextName = servletContext.getServletContextName();
        System.out.println(servletContextName);
        String contextPath = servletContext.getContextPath();
        System.out.println(contextPath);
        String realPath = servletContext.getRealPath("/");
        System.out.println(realPath);
        String serverInfo = servletContext.getServerInfo();
        System.out.println(serverInfo);
        String value = servletContext.getInitParameter("glubEncoding");
        System.out.println(value);




    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
